package  chamans.webphp{
	import flash.text.*;
	import flash.events.TextEvent 
		import flash.events.Event; 
	import flash.utils.*;
	
	public class txt extends TextField{
		public var TX:TextField,  style: StyleSheet ,Target:*, Type:*
		public function txt (n:Object):void {
			Target=n['target'] 
			TX=new TextField()
			TX.x=n.x || 0
			TX.y=n.y || 0
			TX.selectable=n.S || false
			Type=n.type || 0
			
			if(Type==0) TX.type = TextFieldType.DYNAMIC;
		 	else {
				TX.type = TextFieldType.INPUT;
				TX.border = true;
				TX.borderColor=0x585858;
				TX.addEventListener(Event.CHANGE, onChange) ;
			}
			
			TX.multiline=n.M || false
			TX.wordWrap=n.W || false
			TX.embedFonts=n.E || false
			TX.condenseWhite = true
			TX.mouseEnabled= n.S || false
			TX.antiAliasType = AntiAliasType.ADVANCED;
			//TX.border = n.B|| false;
			
			TX.height= n.height || 50
			if(n.width){TX.width=n['width'] }
			else{TX.autoSize = TextFieldAutoSize.LEFT }
			style= n['style']  
			update( n['text'] || '')
			Target.addChild(TX);
		}
		public function Remove ():void{  Target.removeChild(TX) 	}
		public function update (texte:*):void{
		 	if(Type==0) TX.styleSheet = style
			TX.htmlText=texte
			if(Type==1) format(TX)
		}
		public function updatef (texte:String):void{
			if(Type==0) TX.styleSheet = style
			TX.htmlText=texte
		}
		public function format (T:TextField):void{
			
		//	T.styleSheet = style
			//style.titre
			//
		var myFormat:TextFormat = new TextFormat();
			myFormat.font = "Vedrana";
			myFormat.color = 0xEEEEEE;
			myFormat.size = 14;
			myFormat.bold = false;
			myFormat.letterSpacing = 1;
		   T.setTextFormat(myFormat);
		}
		
	 	public function onChange(e:Event):void {
	//		var  xml:XML=<xml></xml>
		//	xml.titre=TX.htmlText;
	//	TX.htmlText=xml;
			format(TX)
		}
		public function clear():void {
			Target.removeChild(TX)
		}
		
		
		public function onInput(e:TextEvent):void  {
			trace (">> " + e.type + " -> " + e.currentTarget) ;	
		}
	}}